<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateRoutesTable extends Migration
{
	public function up()
	{
		Schema::create('routes', function($table)
		{
			$table->increments('id');
			$table->string('name', 60);
			$table->integer('parent')->unsigned();
			$table->string('type', 16);
			$table->integer('app_id')->unsigned();
			$table->foreign('app_id')->references('id')->on('apps');
			$table->integer('model_id')->unsigned()->nullable();
			$table->foreign('model_id')->references('id')->on('sources');
			$table->integer('view_id')->unsigned()->nullable();
			$table->foreign('view_id')->references('id')->on('sources');
			$table->integer('controller_id')->unsigned();
			$table->foreign('controller_id')->references('id')->on('sources');
			$table->timestamps();
		});
	}

	public function down()
	{
		Schema::drop('routes');
	}
}
